using Fusion.Hotfix.Mono;
using UnityEngine;
using System;

namespace Fusion.Hotfix
{
    public class DLLUtility
    {
        public static T FindMono<T>(GameObject gameObject, string path) where T : DLLMonoBase
        {
            return (T)FindMono(gameObject, path, typeof(T));
        }

        public static DLLMonoBase FindMono(GameObject gameObject, string path, Type type)
        {
            return FindMono(gameObject, path, type.ToString());
        }

        public static DLLMonoBase FindMono(GameObject gameObject, string path, string type)
        {
            Transform childTransform = gameObject.transform.Find(path);
            if (childTransform != null)
            {
                return childTransform.gameObject.GetMono(type);
            }
            else
            {
                return null;
            }
        }
    }
}

